package org.jeasy.mvc.validate;

import org.jeasy.mvc.validate.annotation.Length;

public class ValidateLength implements ValidateStrategy {
    private Integer min,max,size;//default value is NULL
    private boolean maxMark,minMark;//default value is false
    @Override
	public boolean doCheck(String parameter,Object obj) {
		Length length=(Length)obj;
		min=length.min();
		max=length.max();
		size=parameter.length();	
		if(min!=null) {
			minMark=size>=min?true:false;
		}
	    if(max!=null) {
	    	maxMark=size<=max?true:false;	
	    }
	    if(maxMark&&minMark)return true;
		return false;
	}

}